home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWWindow / Sources / FWWindow.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  21.7 KB  |  697 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWWindow.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWWINDOW_H
  13. #include "FWWindow.h"
  14. #endif
  15.  
  16. #ifndef FWPART_H
  17. #include "FWPart.h"
  18. #endif
  19.  
  20. #ifndef FWACQUIR_H
  21. #include "FWAcquir.h"
  22. #endif
  23.  
  24. #ifndef FWWINPRO_H
  25. #include "FWWinPro.h"
  26. #endif
  27.  
  28. #ifndef FWPRESEN_H
  29. #include "FWPresen.h"
  30. #endif
  31.  
  32. #ifndef FWFCTINF_H
  33. #include "FWFctInf.h"
  34. #endif
  35.  
  36. // ----- Foundation Layer -----
  37.  
  38. #ifndef FWSTRING_H
  39. #include "FWString.h"
  40. #endif
  41.  
  42. // ----- OpenDoc Includes -----
  43.  
  44. #ifndef SOM_ODSession_xh
  45. #include <ODSessn.xh>
  46. #endif
  47.  
  48. #ifndef _ITEXT_
  49. #include "IText.h"
  50. #endif
  51.  
  52. #ifndef SOM_ODFacet_xh
  53. #include <Facet.xh>
  54. #endif
  55.  
  56. #ifndef SOM_ODWindowState_xh
  57. #include <WinStat.xh>
  58. #endif
  59.  
  60. //========================================================================================
  61. //    Runtime Info
  62. //========================================================================================
  63.  
  64. #ifdef FW_BUILD_MAC
  65. #pragma segment fwwindow
  66. #endif
  67.  
  68. FW_DEFINE_CLASS_M0(FW_CWindow)
  69.  
  70. //========================================================================================
  71. // CLASS FW_CWindow
  72. //========================================================================================
  73.  
  74. //----------------------------------------------------------------------------------------
  75. // FW_CWindow::FW_CWindow
  76. //----------------------------------------------------------------------------------------
  77.  
  78. FW_CWindow::FW_CWindow(Environment* ev, 
  79.                         FW_CPart* thePart,
  80.                         ODTypeToken viewType,
  81.                         FW_CPresentation* presentation,
  82.                         const FW_CPoint& interiorSize,
  83.                         const FW_CPoint& position,
  84.                         FW_WindowStyle style) :
  85.     fGraphicDevice(NULL),
  86.     fSession(thePart->GetSession(ev)),
  87.     fWindowID(kODNULLID)
  88. {
  89. FW_UNUSED(viewType);
  90.     FW_CString32 windowTitle("");    // the title doesn't matter
  91.         
  92.     ODWindow* odWindow = PrivCreateODWindow(ev, 
  93.                                             thePart, 
  94.                                             NULL, 
  95.                                             TRUE,     // persistent
  96.                                             FW_CPart::gViewAsFrameToken,
  97.                                             presentation, 
  98.                                             windowTitle, 
  99.                                             interiorSize, 
  100.                                             position,
  101.                                             style);
  102.     PrivOpenWindow(ev, odWindow);
  103.  
  104. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  105.     odWindow->Release(ev);
  106. #endif
  107. }
  108.  
  109. //----------------------------------------------------------------------------------------
  110. // FW_CWindow::FW_CWindow
  111. //----------------------------------------------------------------------------------------
  112.  
  113. FW_CWindow::FW_CWindow(Environment* ev, 
  114.                         FW_CPart* thePart,
  115.                         ODFrame* parentFrame,
  116.                         FW_Boolean persistent,
  117.                         ODTypeToken viewType,
  118.                         FW_CPresentation* presentation,
  119.                         const FW_CString& windowTitle,
  120.                         const FW_CPoint& interiorSize,
  121.                         const FW_CPoint& position,
  122.                         FW_WindowStyle style) :
  123.     fGraphicDevice(NULL),
  124.     fSession(thePart->GetSession(ev)),
  125.     fWindowID(kODNULLID)
  126. {
  127.     ODWindow* odWindow = PrivCreateODWindow(ev, 
  128.                                             thePart, 
  129.                                             parentFrame, 
  130.                                             persistent, 
  131.                                             viewType,
  132.                                             presentation, 
  133.                                             windowTitle, 
  134.                                             interiorSize, 
  135.                                             position,
  136.                                             style);
  137.                     
  138.     PrivOpenWindow(ev, odWindow);
  139.  
  140. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  141.     odWindow->Release(ev);
  142. #endif
  143. }
  144.  
  145. //----------------------------------------------------------------------------------------
  146. // FW_CWindow::FW_CWindow
  147. //----------------------------------------------------------------------------------------
  148.  
  149. FW_CWindow::FW_CWindow(Environment* ev, 
  150.                         FW_CPart* thePart,
  151.                         ODFrame* odFrame) :
  152.     fGraphicDevice(NULL),
  153.     fSession(thePart->GetSession(ev)),
  154.     fWindowID(kODNULLID)
  155. {
  156.     PrivCreateODWindowForFrame(ev, thePart, odFrame);
  157. }
  158.  
  159. //----------------------------------------------------------------------------------------
  160. // FW_CWindow::FW_CWindow
  161. //----------------------------------------------------------------------------------------
  162.  
  163. FW_CWindow::FW_CWindow(Environment* ev, FW_CPart* thePart, ODID windowID) :
  164.     fGraphicDevice(NULL),
  165.     fSession(thePart->GetSession(ev)),
  166.     fWindowID(windowID)
  167. {
  168. }
  169.  
  170. //----------------------------------------------------------------------------------------
  171. // FW_CWindow::~FW_CWindow
  172. //----------------------------------------------------------------------------------------
  173.  
  174. FW_CWindow::~FW_CWindow()
  175. {
  176.     if (fGraphicDevice != 0)
  177.         FW_PrivGDev_Release(fGraphicDevice);
  178. }
  179.  
  180. //----------------------------------------------------------------------------------------
  181. // FW_CWindow::AcquireODWindow
  182. //----------------------------------------------------------------------------------------
  183.  
  184. ODWindow* FW_CWindow::AcquireODWindow(Environment* ev) const
  185. {
  186.     ODID windowID = GetID(ev);    
  187.     FW_ASSERT(windowID != kODNULLID);
  188.  
  189. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  190.     return fSession->GetWindowState(ev)->AcquireWindow(ev, windowID);
  191. #else
  192.     return fSession->GetWindowState(ev)->GetWindow(ev, windowID);
  193. #endif
  194. }
  195.  
  196. //----------------------------------------------------------------------------------------
  197. // FW_CWindow::Show
  198. //----------------------------------------------------------------------------------------
  199.  
  200. void FW_CWindow::Show(Environment* ev)
  201. {
  202.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  203.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  204.     aqODWindow->Show(ev);
  205.     
  206.     // Because hidden floating window are sent to the back
  207.     if (IsFloating(ev))
  208.         Select(ev);
  209. }
  210.  
  211. //----------------------------------------------------------------------------------------
  212. // FW_CWindow::GetWindowTitle
  213. //----------------------------------------------------------------------------------------
  214.  
  215. void FW_CWindow::GetWindowTitle(Environment* ev, FW_CString& windowTitle) const
  216. {
  217.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  218.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  219.     FW_PlatformError error;
  220.     FW_GetWindowTitle(aqODWindow->GetPlatformWindow(ev), windowTitle, &error);
  221.     FW_FailOnError(error);
  222. }
  223.  
  224. //----------------------------------------------------------------------------------------
  225. // FW_CWindow::SetWindowTitle
  226. //----------------------------------------------------------------------------------------
  227.  
  228. void FW_CWindow::SetWindowTitle(Environment* ev, const FW_CString& windowTitle)
  229. {
  230.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  231.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  232.     FW_PlatformError error;
  233.     FW_SetWindowTitle(aqODWindow->GetPlatformWindow(ev), windowTitle, &error);
  234.     FW_FailOnError(error);
  235. }
  236.  
  237. //---------------------------------------------------------------------------------------
  238. //    FW_CWindow::PrivCreateODWindowForFrame
  239. //---------------------------------------------------------------------------------------
  240.  
  241. void FW_CWindow::PrivCreateODWindowForFrame(Environment* ev, 
  242.                                         FW_CPart* thePart,
  243.                                         ODFrame* odFrame)
  244. {
  245. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR2
  246.  
  247.     FW_CWindowProperties props;    
  248.     FW_Boolean hasWinProp = props.ReadWindowProperties(ev, odFrame);
  249.     
  250.     ODPlatformWindow platformWindow = NULL;
  251.     
  252. #ifdef FW_BUILD_MAC
  253.     FW_CPoint interiorSize(props.fBoundsRect.right - props.fBoundsRect.left, 
  254.                             props.fBoundsRect.bottom - props.fBoundsRect.top);
  255.     FW_CPoint position(props.fBoundsRect.left, props.fBoundsRect.top);
  256.  
  257.     platformWindow = FW_PrivMacCreatePlatformWindow(ev, 
  258.                                             props.fMacTitle, 
  259.                                             interiorSize, 
  260.                                             position,             // ATTENTION: position is the inside position
  261.                                             props.fMacProcID, 
  262.                                             props.fMacHasCloseBox,
  263.                                             (long)this);
  264. #endif
  265.  
  266. #ifdef FW_BUILD_WIN
  267.     FW_DEBUG_MESSAGE("Not Implemented Yet!");
  268. #endif    
  269.     
  270.     ODWindowState* windowState = thePart->GetSession(ev)->GetWindowState(ev);
  271.  
  272.     ODWindow* odWindow =  windowState->RegisterWindowForFrame(ev, 
  273.                                                         platformWindow, 
  274.                                                         odFrame,
  275.                                                          props.fIsRootWindow,        // Keeps draft open
  276. #ifdef FW_BUILD_MAC
  277.                                                         FALSE,                        // On the Mac we handle the resizing ourself
  278. #else
  279.                                                         props.fIsResizable,            // Is resizable
  280. #endif
  281.                                                          props.fIsFloating,            // Is floating
  282.                                                         TRUE,                        // should save
  283. #ifdef FW_BUILD_MAC
  284.                                                         TRUE,                        // should dispose
  285. #endif    
  286.                                                         props.fSourceFrame);
  287.     
  288.     SetID(ev, odWindow->GetID(ev));
  289.     
  290.     FW_PlatformError error;
  291.     FW_Boolean changed = FW_FitWindowToScreen(odWindow->GetPlatformWindow(ev), &error);
  292.     FW_FailOnError(error);
  293.     
  294.     odWindow->Open(ev);    // Attention fWindowID has to be set before calling Open
  295.     if (!hasWinProp || changed)
  296.         odWindow->AdjustWindowShape(ev);
  297.  
  298.     odWindow->Release(ev);
  299. #else
  300.     FW_DEBUG_MESSAGE("Should not be called with this version");
  301. #endif
  302. }
  303.  
  304. //---------------------------------------------------------------------------------------
  305. //    FW_CWindow::PrivCreateODWindow
  306. //---------------------------------------------------------------------------------------
  307.  
  308. ODWindow* FW_CWindow::PrivCreateODWindow(Environment* ev, 
  309.                                         FW_CPart* thePart,
  310.                                         ODFrame* parentFrame,
  311.                                         FW_Boolean persistent,
  312.                                         ODTypeToken viewType,
  313.                                         FW_CPresentation* presentation,
  314.                                         const FW_CString& windowTitle,
  315.                                         const FW_CPoint& interiorSize,
  316.                                         const FW_CPoint& position,
  317.                                         FW_WindowStyle style)
  318. {
  319.     ODWindowState* windowState = thePart->GetSession(ev)->GetWindowState(ev);
  320.  
  321.     FW_PlatformError error;
  322. #ifdef FW_BUILD_MAC    
  323.     unsigned short procID = FW_PrivMacStyleToProcId(style);
  324.     
  325.     Str255 pascalTitle;
  326.     windowTitle.ExportPascal(pascalTitle);
  327.  
  328.     FW_CPoint tempSize(FW_IntToFixed(100), FW_IntToFixed(100));
  329.     FW_CPoint tempPos = tempSize;
  330.     ODPlatformWindow platformWindow = FW_PrivMacCreatePlatformWindow(ev, 
  331.                                                                     pascalTitle, 
  332.                                                                     tempSize, 
  333.                                                                     tempPos, 
  334.                                                                     procID,
  335.                                                                     (FW_kHasCloseBox & style) != 0,
  336.                                                                     (long)this);    
  337.     
  338.     // Set the right size
  339.     ::SizeWindow(platformWindow, FW_FixedToInt(interiorSize.x), FW_FixedToInt(interiorSize.y), TRUE);
  340.     
  341.     // because MacCreatePlatformWindow is called with the inside position
  342.     FW_CRect borderSize;
  343.     FW_GetWindowBorderSize(platformWindow, borderSize, &error);
  344.     FW_FailOnError(error);
  345.     ::MoveWindow(platformWindow, 
  346.                 FW_FixedToInt(position.x + borderSize.left),
  347.                 FW_FixedToInt(position.y + borderSize.top), 
  348.                 FALSE);
  349.     
  350.     FW_FitWindowToScreen(platformWindow, &error);
  351.     FW_FailOnError(error);
  352. #endif
  353.  
  354. #ifdef FW_BUILD_WIN
  355.     DWORD windowFlags = FW_PrivWindStyleToWindowsFlags(style);
  356.     
  357.     ODPlatformWindow platformWindow = windowState->CreatePlatformWindow(ev, (style & FW_kFloatingWindow) != 0, windowFlags | WS_CLIPSIBLINGS);
  358.     
  359.     // Associate window pointer with the platform window
  360.     if (platformWindow != NULL)
  361.     {
  362.         ::SetProp(platformWindow, "ODF:Window", (HANDLE) this);
  363.     }
  364. #endif
  365.  
  366.     // ----- Create and return the wrapper window
  367.     ODWindow* odWindow = windowState->RegisterWindow(ev,
  368.                                                     platformWindow, 
  369.                                                     persistent ? kODFrameObject : kODNonPersistentFrameObject,
  370.                                                     (parentFrame == NULL) && ((FW_kFloatingWindow & style) == 0),        // root window
  371. #ifdef FW_BUILD_MAC
  372.                                                     FALSE,        // On the Mac we handle the resizing ourself
  373. #else
  374.                                                     (FW_kResizeable & style) != 0,
  375. #endif
  376.                                                     (FW_kFloatingWindow & style) != 0,
  377.                                                     persistent,        // shouldSave (shouldSave and persistent should always have the same value)
  378. #ifdef FW_BUILD_MAC
  379.                                                     TRUE,                        // should dispose
  380. #endif    
  381.                                                     thePart->GetODPart(ev),
  382.                                                     viewType, 
  383.                                                     presentation->GetPresentationType(ev),
  384.                                                     parentFrame);
  385.     
  386.     return odWindow;
  387. }
  388.  
  389. //---------------------------------------------------------------------------------------
  390. //    FW_CWindow::PrivOpenWindow
  391. //---------------------------------------------------------------------------------------
  392.  
  393. void FW_CWindow::PrivOpenWindow(Environment* ev, ODWindow* odWindow)
  394. {    
  395.     SetID(ev, odWindow->GetID(ev));
  396.  
  397.     FW_PlatformError error;
  398.     FW_FitWindowToScreen(odWindow->GetPlatformWindow(ev), &error);
  399.     FW_FailOnError(error);
  400.  
  401.     odWindow->Open(ev);    // Attention fWindowID has to be set before calling Open
  402. }
  403.  
  404. //----------------------------------------------------------------------------------------
  405. //    FW_CWindow::GetGraphicDevice
  406. //----------------------------------------------------------------------------------------
  407.  
  408. FW_HGDevice FW_CWindow::GetGraphicDevice(Environment* ev) const
  409. {
  410.     FW_CWindow* self = (FW_CWindow *)this;
  411.     
  412.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  413.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  414.     
  415.     ODFacet* rootFacet = aqODWindow->GetRootFacet(ev);
  416.     FW_HGDevice device = FW_GetFacetGraphicDevice(ev, rootFacet);
  417.     
  418.     if (device == NULL)
  419.     {
  420.         if (fGraphicDevice == NULL)        // We never asked for it
  421.         {
  422.             self->fGraphicDevice = FW_PrivGDev_CreateFromODCanvas(ev, rootFacet->GetCanvas(ev));
  423.             FW_FailOnEvError(ev);
  424.         }
  425.         device = fGraphicDevice;
  426.     }    
  427.     
  428.     return device;
  429. }
  430.  
  431. //----------------------------------------------------------------------------------------
  432. //    FW_CWindow::SetWindowSize
  433. //----------------------------------------------------------------------------------------
  434.  
  435. void FW_CWindow::SetWindowSize(Environment* ev, const FW_CPoint& interiorSize)
  436. {    
  437.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  438.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  439.     FW_PlatformError error;
  440.     FW_SetWindowSize(aqODWindow->GetPlatformWindow(ev), interiorSize, &error);
  441.     FW_FailOnError(error);
  442.     
  443.     // ----- Notify the ODWindow -----
  444.     if (aqODWindow->GetRootFacet(ev) != NULL)
  445.         aqODWindow->AdjustWindowShape(ev);
  446. }
  447.  
  448. //----------------------------------------------------------------------------------------
  449. //    FW_CWindow::SetWindowPosition
  450. //----------------------------------------------------------------------------------------
  451. //    newPosition is the position of the exterior top left corner of the window. This is
  452. //    different from the Mac API where MoveWindow takes the inside top left corner
  453. //    of the window. For once the Windows API makes more sense.
  454.  
  455. void FW_CWindow::SetWindowPosition(Environment* ev, const FW_CPoint& newPosition) 
  456. {
  457.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  458.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  459.     FW_PlatformError error;
  460.     FW_SetWindowPosition(aqODWindow->GetPlatformWindow(ev), newPosition, &error);
  461.     FW_FailOnError(error);
  462. }
  463.  
  464. //----------------------------------------------------------------------------------------
  465. //    FW_CWindow::WindowToScreen
  466. //----------------------------------------------------------------------------------------
  467.  
  468. void FW_CWindow::WindowToScreen(Environment* ev,
  469.                                 FW_CPoint* points, 
  470.                                 unsigned short nbPoint)
  471. {
  472.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  473.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  474.     FW_FailOnError(FW_WindowToScreen(aqODWindow->GetPlatformWindow(ev), points, nbPoint));
  475. }
  476.  
  477. //----------------------------------------------------------------------------------------
  478. //    FW_CWindow::ScreenToWindow
  479. //----------------------------------------------------------------------------------------
  480.  
  481. void FW_CWindow::ScreenToWindow(Environment* ev,
  482.                                 FW_CPoint* points, 
  483.                                 unsigned short nbPoint)
  484. {
  485.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  486.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  487.     FW_FailOnError(FW_ScreenToWindow(aqODWindow->GetPlatformWindow(ev), points, nbPoint));
  488. }
  489.  
  490. //----------------------------------------------------------------------------------------
  491. // FW_CWindow::FitToScreen
  492. //----------------------------------------------------------------------------------------
  493.  
  494. void FW_CWindow::FitToScreen(Environment* ev)
  495. {
  496.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);    
  497.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  498.     FW_PlatformError error;
  499.     FW_FitWindowToScreen(aqODWindow->GetPlatformWindow(ev), &error);
  500.     FW_FailOnError(error);
  501. }
  502.  
  503. //----------------------------------------------------------------------------------------
  504. //    FW_CWindow::GetWindowSize
  505. //----------------------------------------------------------------------------------------
  506. // Returns the inside size of the window
  507.  
  508. void FW_CWindow::GetWindowSize(Environment* ev, FW_CPoint& interiorSize) const
  509. {
  510.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  511.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  512.     FW_PlatformError error;
  513.     FW_GetWindowSize(aqODWindow->GetPlatformWindow(ev), interiorSize, &error);
  514.     FW_FailOnError(error);
  515. }
  516.  
  517. //----------------------------------------------------------------------------------------
  518. //    FW_CWindow::GetWindowPosition
  519. //----------------------------------------------------------------------------------------
  520. // Returns the outside position of the window
  521.  
  522. void FW_CWindow::GetWindowPosition(Environment* ev, FW_CPoint& position) const
  523. {
  524.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  525.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  526.     FW_PlatformError error;
  527.     FW_GetWindowPosition(aqODWindow->GetPlatformWindow(ev), position, &error);
  528.     FW_FailOnError(error);
  529. }
  530.  
  531. //----------------------------------------------------------------------------------------
  532. // FW_CWindow::IsFloating
  533. //----------------------------------------------------------------------------------------
  534.  
  535. FW_Boolean FW_CWindow::IsFloating(Environment* ev) const
  536. {
  537. FW_UNUSED(ev);
  538.     return FALSE;
  539. }
  540.  
  541. //----------------------------------------------------------------------------------------
  542. // FW_CWindow::IsActive
  543. //----------------------------------------------------------------------------------------
  544.  
  545. FW_Boolean FW_CWindow::IsActive(Environment* ev) const
  546. {
  547.     if (GetID(ev) != kODNULLID)
  548.     {
  549.         FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  550.         FW_ASSERT((ODWindow*)aqODWindow != NULL);
  551.         return aqODWindow->IsActive(ev);
  552.     }
  553.     else
  554.         return FALSE;
  555. }
  556.  
  557. //----------------------------------------------------------------------------------------
  558. // FW_CWindow::GetID
  559. //----------------------------------------------------------------------------------------
  560.  
  561. ODID FW_CWindow::GetID(Environment* ev) const
  562. {
  563. FW_UNUSED(ev);
  564.     return fWindowID;
  565. }
  566.  
  567. //----------------------------------------------------------------------------------------
  568. // FW_CWindow::SetID
  569. //----------------------------------------------------------------------------------------
  570.  
  571. void FW_CWindow::SetID(Environment* ev, ODID windowID)
  572. {
  573. FW_UNUSED(ev);
  574.     FW_ASSERT(fWindowID == kODNULLID || fWindowID == windowID);
  575.     fWindowID = windowID;
  576. }
  577.  
  578. //----------------------------------------------------------------------------------------
  579. // FW_CWindow::GetPlatformWindow
  580. //----------------------------------------------------------------------------------------
  581.  
  582. ODPlatformWindow FW_CWindow::GetPlatformWindow(Environment* ev) const
  583. {
  584.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  585.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  586.     return aqODWindow->GetPlatformWindow(ev);
  587. }
  588.  
  589. //----------------------------------------------------------------------------------------
  590. //    FW_CWindow::GetBorderSize
  591. //----------------------------------------------------------------------------------------
  592.  
  593. void FW_CWindow::GetBorderSize(Environment* ev, FW_CRect &borderSize) const
  594. {
  595.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  596.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  597.     FW_PlatformError error;
  598.     FW_GetWindowBorderSize(aqODWindow->GetPlatformWindow(ev), borderSize, &error);
  599.     FW_FailOnError(error);
  600. }
  601.  
  602. //----------------------------------------------------------------------------------------
  603. //    FW_CWindow::Close
  604. //----------------------------------------------------------------------------------------
  605.  
  606. void FW_CWindow::Close(Environment* ev)
  607. {
  608.     if (GetID(ev) != kODNULLID)
  609.     {
  610.         FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  611.         FW_ASSERT((ODWindow*)aqODWindow != NULL);
  612.         aqODWindow->Close(ev);
  613.     }
  614. }
  615.  
  616. //----------------------------------------------------------------------------------------
  617. //    FW_CWindow::CloseAndRemove
  618. //----------------------------------------------------------------------------------------
  619.  
  620. void FW_CWindow::CloseAndRemove(Environment* ev)
  621. {
  622.     if (GetID(ev) != kODNULLID)
  623.     {
  624.         // Don't use a FW_CAcquiredODWindow object here because CloseAndRemove
  625.         // already releases it
  626.         ODWindow* odWindow = AcquireODWindow(ev);
  627.         FW_ASSERT(odWindow);
  628.         odWindow->CloseAndRemove(ev);
  629.     }
  630. }
  631.  
  632. //----------------------------------------------------------------------------------------
  633. //    FW_CWindow::Select
  634. //----------------------------------------------------------------------------------------
  635.  
  636. void FW_CWindow::Select(Environment* ev) const
  637. {
  638.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  639.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  640.     aqODWindow->Select(ev);
  641. }
  642.  
  643. //----------------------------------------------------------------------------------------
  644. //    FW_CWindow::IsShown
  645. //----------------------------------------------------------------------------------------
  646.  
  647. FW_Boolean FW_CWindow::IsShown(Environment* ev) const
  648. {
  649.     if (GetID(ev) != kODNULLID)
  650.     {
  651.         FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  652.         FW_ASSERT((ODWindow*)aqODWindow != NULL);
  653.         return aqODWindow->IsShown(ev);
  654.     }
  655.     else
  656.         return FALSE;
  657. }
  658.  
  659. //----------------------------------------------------------------------------------------
  660. // FW_CWindow::Hide
  661. //----------------------------------------------------------------------------------------
  662.  
  663. void FW_CWindow::Hide(Environment* ev)
  664. {
  665.     if (GetID(ev) != kODNULLID)
  666.     {
  667.         FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  668.         FW_ASSERT((ODWindow*)aqODWindow != NULL);
  669.         aqODWindow->Hide(ev);
  670.     }
  671. }
  672.  
  673. #ifdef FW_BUILD_MAC
  674. //----------------------------------------------------------------------------------------
  675. //    FW_CWindow::PrivMacDoZoom
  676. //----------------------------------------------------------------------------------------
  677.  
  678. void FW_CWindow::PrivMacDoZoom(Environment* ev,
  679.                             const FW_CPoint& zoomedSize, 
  680.                             const FW_CRect& borderSize,
  681.                             const FW_CRect& screenRect,
  682.                             unsigned long message)
  683. {
  684.     FW_CAcquiredODWindow aqODWindow = AcquireODWindow(ev);
  685.     FW_ASSERT((ODWindow*)aqODWindow != NULL);
  686.     
  687.     ODPlatformWindow platformWindow = aqODWindow->GetPlatformWindow(ev);
  688.     
  689.     FW_PlatformError error;
  690.     FW_PrivMacDoZoom(platformWindow, zoomedSize, borderSize, screenRect, message, &error);
  691.     FW_FailOnError(error);
  692.     
  693.     aqODWindow->AdjustWindowShape(ev);
  694. }
  695. #endif
  696.  
  697.